/**
 * 
 */
package com.example.ourapps.mvc;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.example.ourapps.domain.AppDetail;
import com.example.ourapps.repo.AppDetailDao;

/**
 * @author richapahwa
 *
 */
@Controller
@RequestMapping("/rest/appDetails")
public class AppDetailRestController {

	@Autowired
	private AppDetailDao appDetailDao;
	
	@RequestMapping(method=RequestMethod.GET, produces="application/json")
	public @ResponseBody List<AppDetail> listAllApplications() {
		return appDetailDao.findAllRegisteredApps();
	}
	
	@RequestMapping(value="/{anApplicationId}", method=RequestMethod.GET, produces="application/json")
	public @ResponseBody AppDetail lookupApplicationById(@PathVariable ("anApplicationId") final Long anApplicationId) {
		return appDetailDao.findById(anApplicationId);
	}
}
